@IsTest private class DiscussionReplyTest {
    public static testMethod void testDiscussion() {   
         
        try{ 

	    	TeamUtil.isTest = true;    	
        	GenerateEnvironmentTest.gen();
    		Test.startTest();
            DiscussionReplyController dis = new DiscussionReplyController();
            DiscussionForum__c myTeam = GenerateEnvironmentTest.newDiscussionforum;
            dis.setTEAMID(myTeam.Id);
            DiscussionTopic__c newTopic = new DiscussionTopic__c();
            newTopic.ViewCount__c = 1;
            newTopic.Threaded__c = false;
            
            String idTeam = GenerateEnvironmentTest.newDiscussionforum.id;
            
            String idDiscussionForum = GenerateEnvironmentTest.newDiscussionforum.id;
            newTopic.DiscussionForum__c = idDiscussionForum;
            
            newTopic.Subject__c = 'Code Coverage';
            newTopic.Stickied__c = false;
            newTopic.PostedDate__c = System.now();
            newTopic.PostedBy__c = UserInfo.getUserId();
            newTopic.MessageCount__c = 0;
            newTopic.Locked__c = false;
            newTopic.LastViewedDate__c = System.now();
            
            insert newTopic;
            
            DiscussionMessage__c newMessage = new DiscussionMessage__c();
            newMessage.PostedDate__c = System.now();
            newMessage.Message__c = 'Replay to Topic';
            newMessage.DiscussionTopic__c = newTopic.id;
            newMessage.Discussion__c = idTeam;
            newMessage.Subject__c = 'Reply to Topic';
            
            insert newMessage;
            
            DiscussionMessage__c newReply = new DiscussionMessage__c();
            newReply.PostedDate__c = System.now();
            newReply.ParentMessage__c = newMessage.Id;
            newReply.Message__c = 'Reply to Message';
            newReply.DiscussionTopic__c = newTopic.id;
            newReply.Discussion__c = idTeam;
            newReply.Subject__c = 'Reply to Message';
       		
            String idDiscussionTopic = newTopic.Id;
            dis.setParamId(idDiscussionTopic);
            
            dis.setPageNumberParam('');
            
            dis.constructorMethods();
            
            if (dis.getUserPermissions() == null) {
                System.assert(true, 'Null Permissions');
            }
            
            if (dis.getIsTopicAuthor() == null) {
                System.assert(true, 'Null isTopicAuthor boolean');
            }   
            
            if (dis.getIsTeamAdminMember() == null) {
                System.assert(true, 'Null getIsTeamAdminMember boolean');
            }
            
            dis.saveReply();
            
            if (dis.getNoForums() == null) {
                System.assert(true, 'Null getNoForums boolean');
            }
            
            dis.setTopicIdParam(idDiscussionTopic);
            dis.updateReadCount();
            
            /* Pagination */
            dis.currentPagination = 1;
            dis.cntPagination = 2;
            Boolean b1 = dis.getPrevPageLinkShow();
            Boolean b2 = dis.getPrevPageShow();
            Boolean b3 = dis.getNextPageLinkShow();
            Boolean b4 = dis.getNextPageShow();
            
            dis.currentPagination = 0;
            dis.cntPagination = 0;
            b1 = dis.getPrevPageLinkShow();
            b2 = dis.getPrevPageShow();
            b3 = dis.getNextPageLinkShow();
            b4 = dis.getNextPageShow();
            
            dis.currentPagination = 3;
            dis.cntPagination = 0;
            b1 = dis.getPrevPageLinkShow();
            b2 = dis.getPrevPageShow();
            b3 = dis.getNextPageLinkShow();
            b4 = dis.getNextPageShow();
            
            dis.nextPage();
            dis.prevPage();
            dis.getCurrentPagination();
            dis.getCntPagination();
            dis.getNumberOfItemsToShow();
            dis.getFirstRow();
            dis.getPrevPageLinkShow();
            dis.getPrevPageShow();
            dis.getNextPageLinkShow();
            dis.getNextPageShow();
            
            dis.getForumData();
            dis.deleteReplyId();
            
            dis.getTopicUser();
            DiscussionReplyController.UserTopic userTopicClass = new DiscussionReplyController.UserTopic(GenerateEnvironmentTest.newUser, GenerateEnvironmentTest.newMessage, GenerateEnvironmentTest.newDiscussionForum, GenerateEnvironmentTest.newTopic.Id );
            userTopicClass.getPicture();
            userTopicClass.getUser();
            userTopicClass.getTeam();
            userTopicClass.getTopic();
            userTopicClass.getMessTopic();
            userTopicClass.getTopicNameReplaced();
            
            DiscussionReplyController.UserReplys userReplysClass = new DiscussionReplyController.UserReplys( GenerateEnvironmentTest.newMessage );
            userReplysClass.getIsMessageAuthor();
            userReplysClass.getQtAuthor();
            userReplysClass.getQuote();
            userReplysClass.getQtdate();
            userReplysClass.getExistqt();
            userReplysClass.getUser();
            userReplysClass.getUserShortName();
            userReplysClass.getMessage();
            userReplysClass.getPicture();
            userReplysClass.getStrdate();
            
            //Save Methods
            dis.saveReply();
  
            
            Id ide = dis.getTopicId();
            DiscussionMessage__c fstMsg = dis.getFirstMessage();

			dis.setParamId('1');
			dis.setPageNumberParam('1');
			dis.constructorMethods();
			dis.getPrevPageLinkShow();
            
            Test.stopTest();
        }catch(Exception e){
            throw e;
        }
        
    }
     public static testMethod void testDiscussion2() {   
         
        try{ 

	    	TeamUtil.isTest = true;    	
        	GenerateEnvironmentTest.gen();
    		Test.startTest();
    		  
            DiscussionReplyController dis = new DiscussionReplyController();
            dis.setParamId( GenerateEnvironmentTest.newDiscussionForum.Id );
            DiscussionForum__c myTeam = GenerateEnvironmentTest.newDiscussionforum;
            dis.setDeleteReplyId(GenerateEnvironmentTest.newMessage.Id);
            /*
            DiscussionTopic__c newM = new DiscussionTopic__c();
            newM.DiscussionForum__c = GenerateEnvironmentTest.newDiscussionForum.Id;
            insert newM;
            dis.setDeleteReplyId( newM.Id);
            */
            dis.deleteReply();
            
            dis.setTEAMID( GenerateEnvironmentTest.newDiscussionForum.Id );
            dis.getForumData();
            
            DiscussionReplyController.replyMessage rplNew = new DiscussionReplyController.replyMessage();
            rplNew.Message = 'fdasfads';
            rplNew.ParentMessage = 'fdasfads';
            rplNew.MessageId = 'fdasfads';
            
            dis.saveNewTopicReply();            
            DiscussionReplyController.replyMessage rplget = dis.getQuoteReply();
            dis.saveQuoteReply();
            
            DiscussionMessage__c msg = [Select Id, Message__c from  DiscussionMessage__c Limit 1];
            
            rplNew.Message = msg.Message__c;
            rplNew.ParentMessage = msg.Id;
            rplNew.MessageId = msg.Id;
            
            DiscussionReplyController.replyMessage rplget2 = dis.getQuoteReply();
            dis.saveNewTopicReply();
            dis.saveQuoteReply();             
            Test.stopTest();
        }catch(Exception e){
            throw e;
        }              
	}
}